package zkj.servlet;

import java.io.IOException;

import javax.servlet.GenericServlet;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;

public class ServletDemo1 extends GenericServlet {
	/**
	 * 
	 */

	private static final long serialVersionUID = 1L;

	public ServletDemo1() {
		System.out.println("Demo1默认构造方法~");

	}

	@Override
	public void init() throws ServletException {
		System.out.println("Dmeo1初始化~");
	}

	@Override
	public void service(ServletRequest req, ServletResponse res)
			throws ServletException, IOException {
		// res.setCharacterEncoding("utf-8");// 解决中文乱码问题
		// res.setContentType("text/html;charset=UTF-8");
		res.getWriter().write("我的第一个servletDemo");
		res.getWriter().write("</br>");
		res.getWriter().write("Hello Servlet");
		System.out.println("ServletDemo1的services方法");
	}

	@Override
	public void destroy() {
		System.out.println("Demo1销毁方法");// cmd e: ;cd ~~ ; shutdown.bat
	}

}
